using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Services;

namespace Scopa.Menu
{
    using Locale = ScopaLocale;

    public enum scopa
    {
        yellow,
        red,
        violet,

    }

    public class BackgroundMenu : BaseMenu
    {
        SpriteBatch spriteBatch;
        private Color colorFog = Color.White, colorBackground = Color.Transparent;
        private Texture2D fog, box, logo;

        public BackgroundMenu(Game game, MenuDepths depth)
            : base(game, depth)
        {
            spriteBatch = Game.GetScopaContext().SpriteBatch;

            background = game.Content.Load<Texture2D>(@"Images//Menu//sfondoScopa");
            //background2 = game.Content.Load<Texture2D>(@"Images//Menu//sfondoScopa");
            //fog = game.Content.Load<Texture2D>(@"Images//Menu//fog");
            box = game.Content.Load<Texture2D>(@"Images//Menu//roundedBox");
            logo = game.Content.Load<Texture2D>(@"Images//Menu//scopalone" + (int)scopa.red);

            bounds = game.GraphicsDevice.Viewport.Bounds;
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }

        //private float delta, delta2;
        //private int segno = 1, backgroundsCount = 2, fogx = 0, clr = 0;

        public override void Update(GameTime gameTime)
        {
            //delta += 0.0123f;
            //delta2 += 0.01f * segno;
            //fogx++;
            //clr++;

            //if (fogx > 600) fogx = 0;



            //if (clr > 60)
            //{
            //    if (fogx % 2 == 0)
            //        logo = Game.Content.Load<Texture2D>(@"Images//Menu//scopalone" + (int)scopa.violet);
            //    clr = 0;
            //}
            //else
            //    if (fogx % 2 == 0)
            //        logo = Game.Content.Load<Texture2D>(@"Images//Menu//scopalone" + (int)scopa.red);



            //if (delta >= 1.0f)
            //{
            //    delta = 0.0f;
            //    background = background2;
            //    background2 = Game.Content.Load<Texture2D>(@"Images//Menu//sfondoScopa");

            //    colorBackground = Color.Transparent;

            //    backgroundsCount++;
            //    backgroundsCount %= 5;
            //    segno = segno * -1;

            //}
            //else
            //{
            //    colorBackground = Color.Lerp(Color.Transparent, Color.White, delta);
            //    if (delta2 < 1.0f || delta2 > 0.0f) colorFog = Color.Lerp(Color.Transparent, Color.White, delta2);
            //}
        }

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);

            // Background
            //spriteBatch.Draw(background, bounds, null, Color.White, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);
            //spriteBatch.Draw(background2, bounds, null, colorBackground, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);

            // Box
            spriteBatch.Draw(box, new Rectangle(55, 80, 300, 250), null, new Color(100, 100, 100, 100), 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);

            // Box
            spriteBatch.Draw(box, new Rectangle(bounds.X + 450, 10, 310, 60), null, new Color(50, 200, 150, 100), 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);

            //LOGO
            spriteBatch.Draw(logo, new Rectangle(300, 40, 540, 366), null, Color.White);

            // Fog
            //DrawFog();

            spriteBatch.End();
        }

        private void DrawFog()
        {
            //spriteBatch.Draw(fog, new Rectangle(150 + 5 * (int)delta, 400, 300, 100), null, colorFog, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);
            ////spriteBatch.Draw(fog, new Rectangle(450 + 5 * (int)delta, 390, 300, 100), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);
            //spriteBatch.Draw(fog, new Rectangle(600 + 4 * (int)delta, 420, 300, 100), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);

            //spriteBatch.Draw(fog, new Rectangle(100, 400 + (int)(delta2 * 2), 300, 100), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);
            //spriteBatch.Draw(fog, new Rectangle(400, 390 + (int)(delta2 * 1), 300, 100), null, colorFog, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);
            ////spriteBatch.Draw(fog, new Rectangle(500, 420 + (int)(delta2 * 2), 300, 100), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);

            //spriteBatch.Draw(fog, new Rectangle(fogx - 600, 400 + (int)(delta2 * 2), 600, 100), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);
            //spriteBatch.Draw(fog, new Rectangle(fogx, 400 + (int)(delta2 * 2), 600, 100), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);
            //spriteBatch.Draw(fog, new Rectangle(550 + fogx, 390 + (int)(delta2 * 3), 600, 100), null, colorFog, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);

            //spriteBatch.Draw(fog, new Rectangle(600 - fogx, 400 + (int)(delta2 * 2), 600, 100), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);
            //spriteBatch.Draw(fog, new Rectangle(-fogx, 400 + (int)(delta2 * 2), 600, 100), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);


            ////spriteBatch.Draw(fog, new Rectangle(0 + (int)(delta * 2), 400, 300, 100), null, color1, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);
            //spriteBatch.Draw(fog, new Rectangle(300 + (int)(delta * 2), 390, 300, 100), null, colorFog, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);
            //spriteBatch.Draw(fog, new Rectangle(600 + (int)(delta * 2), 420, 300, 100), null, colorFog, 0, Vector2.Zero, SpriteEffects.None, (float)DrawOrder / (float)MenuDepths.numMenus);

            ////LOGO
            //spriteBatch.Draw(logo, new Rectangle(300, 40, 540, 366), null, Color.White);
        }
    }
}
